package com.token.sysflow.bean;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import com.token.sql.IntegrateSql;
import com.token.sql.AbstractTableBean;
/**
 * 环节子流程行项目
 * @author 代码创建
 */
public class FlowStepSubflowSub extends AbstractTableBean {

	private String SubFlowID; //主键
	private String StepId; //环节ID
	private String FlowId; //流程ID
	private String SubFlowName; //子流程名称
	private String InnerFormName; //指定子表单名
	private String SubFlowFlag; //子流程标识
	private String SelectSubFlow; //指定子流程
	private String ReturnResult; //执行条件
	private String FieldForWrite; //回写字段
	private String SubFlowFile; //表单字段
	private String Sortby; //排列次序

	public static String TABLE_NAME = "Flow_StepSubflow_Sub";
	public static String TABLEKEY_NAME = "SubFlowID";
	public FlowStepSubflowSub (IntegrateSql f){
		super(f,TABLE_NAME);
		this.setKeyName(TABLEKEY_NAME);
	}

	public FlowStepSubflowSub (IntegrateSql f,ResultSet rs) throws SQLException{
		super(f,TABLE_NAME);
		this.setKeyName(TABLEKEY_NAME);
		this.initParamToRs(rs);
	}

	public FlowStepSubflowSub (IntegrateSql f,String keyValue) throws SQLException{
		super(f,TABLE_NAME);
		this.setKeyName(TABLEKEY_NAME);
		setCodePrepare(selectCodeById().toString());
		prepareSql.setPstValue(1, keyValue);
		ResultSet rs = executeQuery();
		if(rs.next()){
			initParamToRs(rs);
		}else{
			initParam();
		}
		rs.close();
	}

	@Override
	protected void initParam() {
		SubFlowID = ""; //主键
		StepId = ""; //环节ID
		FlowId = ""; //流程ID
		SubFlowName = ""; //子流程名称
		InnerFormName = ""; //指定子表单名
		SubFlowFlag = ""; //子流程标识
		SelectSubFlow = ""; //指定子流程
		ReturnResult = ""; //执行条件
		FieldForWrite = ""; //回写字段
		SubFlowFile = ""; //表单字段
		Sortby = ""; //排列次序
	}


	public void initParamToRs(ResultSet rs) throws SQLException{
		SubFlowID = rs.getString("SubFlowID"); //主键
		StepId = rs.getString("StepId"); //环节ID
		FlowId = rs.getString("FlowId"); //流程ID
		SubFlowName = rs.getString("SubFlowName"); //子流程名称
		InnerFormName = rs.getString("InnerFormName"); //指定子表单名
		SubFlowFlag = rs.getString("SubFlowFlag"); //子流程标识
		SelectSubFlow = rs.getString("SelectSubFlow"); //指定子流程
		ReturnResult = rs.getString("ReturnResult"); //执行条件
		FieldForWrite = rs.getString("FieldForWrite"); //回写字段
		SubFlowFile = rs.getString("SubFlowFile"); //表单字段
		Sortby = rs.getString("Sortby"); //排列次序
		this.setKeyId(rs.getString("SubFlowID"));
	}


	@Override
	protected int appendData() throws SQLException {
		int i = 1;
		prepareSql.setPstValue(i++,SubFlowID); //主键
		prepareSql.setPstValue(i++,StepId); //环节ID
		prepareSql.setPstValue(i++,FlowId); //流程ID
		prepareSql.setPstValue(i++,SubFlowName); //子流程名称
		prepareSql.setPstValue(i++,InnerFormName); //指定子表单名
		prepareSql.setPstValue(i++,SubFlowFlag); //子流程标识
		prepareSql.setPstValue(i++,SelectSubFlow); //指定子流程
		prepareSql.setPstValue(i++,ReturnResult); //执行条件
		prepareSql.setPstValue(i++,FieldForWrite); //回写字段
		prepareSql.setPstValue(i++,SubFlowFile); //表单字段
		prepareSql.setPstValue(i++,Sortby); //排列次序
		return i;
	}


	@Override
	public Vector<String> getFields() {
		Vector<String> vec = new Vector<String>();
		vec.addElement("SubFlowID"); //主键
		vec.addElement("StepId"); //环节ID
		vec.addElement("FlowId"); //流程ID
		vec.addElement("SubFlowName"); //子流程名称
		vec.addElement("InnerFormName"); //指定子表单名
		vec.addElement("SubFlowFlag"); //子流程标识
		vec.addElement("SelectSubFlow"); //指定子流程
		vec.addElement("ReturnResult"); //执行条件
		vec.addElement("FieldForWrite"); //回写字段
		vec.addElement("SubFlowFile"); //表单字段
		vec.addElement("Sortby"); //排列次序
		return vec;
	}


	/**
	 * 设置主键
	 * @param subflowid
	 */
	public void setSubFlowID(String subflowid){
		SubFlowID = subflowid;
	}
	/**
	 * 获取SubFlowID
	 * @return 主键
	 */
	public String getSubFlowID(){
		return SubFlowID;
	}

	/**
	 * 设置环节ID
	 * @param stepid
	 */
	public void setStepId(String stepid){
		StepId = stepid;
	}
	/**
	 * 获取StepId
	 * @return 环节ID
	 */
	public String getStepId(){
		return StepId;
	}

	/**
	 * 设置流程ID
	 * @param flowid
	 */
	public void setFlowId(String flowid){
		FlowId = flowid;
	}
	/**
	 * 获取FlowId
	 * @return 流程ID
	 */
	public String getFlowId(){
		return FlowId;
	}

	/**
	 * 设置子流程名称
	 * @param subflowname
	 */
	public void setSubFlowName(String subflowname){
		SubFlowName = subflowname;
	}
	/**
	 * 获取SubFlowName
	 * @return 子流程名称
	 */
	public String getSubFlowName(){
		return SubFlowName;
	}

	/**
	 * 设置指定子表单名
	 * @param innerformname
	 */
	public void setInnerFormName(String innerformname){
		InnerFormName = innerformname;
	}
	/**
	 * 获取InnerFormName
	 * @return 指定子表单名
	 */
	public String getInnerFormName(){
		return InnerFormName;
	}

	/**
	 * 设置子流程标识
	 * @param subflowflag
	 */
	public void setSubFlowFlag(String subflowflag){
		SubFlowFlag = subflowflag;
	}
	/**
	 * 获取SubFlowFlag
	 * @return 子流程标识
	 */
	public String getSubFlowFlag(){
		return SubFlowFlag;
	}

	/**
	 * 设置指定子流程
	 * @param selectsubflow
	 */
	public void setSelectSubFlow(String selectsubflow){
		SelectSubFlow = selectsubflow;
	}
	/**
	 * 获取SelectSubFlow
	 * @return 指定子流程
	 */
	public String getSelectSubFlow(){
		return SelectSubFlow;
	}

	/**
	 * 设置执行条件
	 * @param returnresult
	 */
	public void setReturnResult(String returnresult){
		ReturnResult = returnresult;
	}
	/**
	 * 获取ReturnResult
	 * @return 执行条件
	 */
	public String getReturnResult(){
		return ReturnResult;
	}

	/**
	 * 设置回写字段
	 * @param fieldforwrite
	 */
	public void setFieldForWrite(String fieldforwrite){
		FieldForWrite = fieldforwrite;
	}
	/**
	 * 获取FieldForWrite
	 * @return 回写字段
	 */
	public String getFieldForWrite(){
		return FieldForWrite;
	}

	/**
	 * 设置表单字段
	 * @param subflowfile
	 */
	public void setSubFlowFile(String subflowfile){
		SubFlowFile = subflowfile;
	}
	/**
	 * 获取SubFlowFile
	 * @return 表单字段
	 */
	public String getSubFlowFile(){
		return SubFlowFile;
	}

	/**
	 * 设置排列次序
	 * @param sortby
	 */
	public void setSortby(String sortby){
		Sortby = sortby;
	}
	/**
	 * 获取Sortby
	 * @return 排列次序
	 */
	public String getSortby(){
		return Sortby;
	}

}
